<?php session_start();
require('globals/setup.php');
$smarty = new Smarty_Kalender;	

$host  = $_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_NAME'] == 'localhost'){$uri= URI_L;}else{$uri= URI_P;}
if (!isset($_SESSION['id_user']) || $_SESSION['id_user']=='') {
	echo "<script language=Javascript> location.href='http://$host$uri/index.php'; </script>";	
}else{
	
	if (!is_object($bd)){	
		require("globals/Db.class.php");
		require("globals/Conf.class.php");
		$bd=Db::getInstance();
	}
	if (!is_object($util)){	
		include("globals/Util.class.php");
		$util=Util::getInstance();
	}
		
	if (!($util->administrarTiempoSesion())){
		echo "<script language=Javascript> location.href='http://$host$uri/timeout.php'; </script>";
	}else if (!($util->administrarAcceso("facturacion"))){
		echo "<script language=Javascript> location.href='http://$host$uri/sinAcceso.php'; </script>";
	}
	
	$id_user = $_SESSION['id_user'];

	$idNC = $_GET["aid"];
	if ($util->isThisNCEditable($bd, $idNC)){
		$smarty->assign("idNC", $idNC);
			
		$NC_data = $util->getDataFromIDNC($bd, $idNC);
		$smarty->assign("idClienteStr", $NC_data["idClienteStr"]);
		$smarty->assign("desc", $NC_data["desc"]);
		$smarty->assign("valor", $NC_data["valor"]);
		
		$smarty->assign("menuItem", "ot");
		include("globals/menuIzquierda.php");
		$smarty->display("edicionNC.tpl");
	}else{
		$smarty->assign("menuItem", "ot");
		include("globals/menuIzquierda.php");			
		$smarty->display("edicionNC_error.tpl");
	}
	

} //del if grande ?>